package com.kun.portal.webframe.po;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;

import com.kun.portal.webframe.util.LazyIgnore;
import com.kun.portal.webframe.util.Loaded;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.collection.spi.PersistentCollection;
import org.springframework.context.annotation.Lazy;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.Date;
import java.util.Set;

/**
 * Created by Administrator on 2018/7/5.
 */
@Entity
@Table(
        name = "fbo_equipment"
)
@NamedEntityGraph(name = "lazy",
        attributeNodes = {@NamedAttributeNode("maintenancePlanSettings"),
                @NamedAttributeNode("repairPlaneSettings")})
@DynamicUpdate

public class EquipmentPo {
    @Id
    @GeneratedValue(
            generator = "id"
    )
    @GenericGenerator(
            name = "id",
            strategy = "uuid"
    )
    @Column(
            name = "id",
            length = 32,
            nullable = false
    )
    private String  id;
    @Column(
            name = "equipment_name",
            length = 32

    )
    private String equipmentName;
    @Column(
            name = "specifications",
            length = 32


    )
    private String specifications;

    @Column(
            name = "make_date"

    )
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @JsonFormat(pattern="yyyy-MM-dd",timezone="Asia/Shanghai")
    @Temporal(TemporalType.DATE)
    private Date makeDate;



    @DateTimeFormat(pattern="yyyy-MM-dd")
    @JsonFormat(pattern="yyyy-MM-dd",timezone="Asia/Shanghai")
    @Temporal(TemporalType.DATE)
    @Column(
            name = "use_date"

    )
    private Date useDate;
    @Column(
            name = "status",
            length = 32


    )
    private String status;
    @Column(
            name = "equipment_num",
            length = 32

    )
    private String equipmentNum;
    @Column(
            name = "manufacturing_no",
            length = 32

    )
    private String manufacturingNo;
    @Column(
            name = "team_name",
            length = 32

    )
    private String teamName;
    @Column(
            name = "team_id",
            length = 32

    )
    private String teamId;



    @OneToMany(targetEntity=MaintenancePlanSettingPo.class, cascade = CascadeType.REMOVE, fetch = FetchType.LAZY,mappedBy = "equipmentPo")
    private Set<MaintenancePlanSettingPo> maintenancePlanSettings;


    @OneToMany(targetEntity=RepairPlaneSettingPo.class, cascade = CascadeType.REMOVE, fetch = FetchType.LAZY ,mappedBy = "equipmentPo")
    private Set<RepairPlaneSettingPo> repairPlaneSettings;


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getEquipmentName() {
        return equipmentName;
    }

    public void setEquipmentName(String equipmentName) {
        this.equipmentName = equipmentName;
    }

    public String getSpecifications() {
        return specifications;
    }

    public void setSpecifications(String specifications) {
        this.specifications = specifications;
    }

    public Date getMakeDate() {
        return makeDate;
    }

    public void setMakeDate(Date makeDate) {
        this.makeDate = makeDate;
    }

    public Date getUseDate() {
        return useDate;
    }

    public void setUseDate(Date useDate) {
        this.useDate = useDate;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getEquipmentNum() {
        return equipmentNum;
    }

    public void setEquipmentNum(String equipmentNum) {
        this.equipmentNum = equipmentNum;
    }

    public String getManufacturingNo() {
        return manufacturingNo;
    }

    public void setManufacturingNo(String manufacturingNo) {
        this.manufacturingNo = manufacturingNo;
    }

    @LazyIgnore
    public String getTeamName() {
        return teamName;
    }

    public void setTeamName(String teamName) {
        this.teamName = teamName;
    }


    public String getTeamId() {
        return teamId;
    }

    public void setTeamId(String teamId) {
        this.teamId = teamId;
    }



    public Set<MaintenancePlanSettingPo> getMaintenancePlanSettings() {
        return (Set<MaintenancePlanSettingPo>) Loaded.loaded(maintenancePlanSettings);
    }

    public Set<RepairPlaneSettingPo> getRepairPlaneSettings() {
        return (Set<RepairPlaneSettingPo>) Loaded.loaded(repairPlaneSettings);
    }

    public void setMaintenancePlanSettings(Set<MaintenancePlanSettingPo> maintenancePlanSettings) {
        this.maintenancePlanSettings = maintenancePlanSettings;
    }



    public void setRepairPlaneSettings(Set<RepairPlaneSettingPo> repairPlaneSettings) {
        this.repairPlaneSettings = repairPlaneSettings;
    }
}
